package user;

import java.util.Date;
import java.util.Scanner;

public class User {
    private int id; // 唯一ID
    private String userName; // 唯一用户名
    private String password;
    private String userType; // 管理员/经理/前台
    private String userTelephone; // 唯一电话
    private Date registerTime; // 注册时间（不可修改）
    private boolean needChangePassword; // 是否需登录时修改密码
    protected static Scanner scanner = new Scanner(System.in); // 共享扫描器

    // 构造方法
    public User() {}

    public User(int id, String userName, String password, String userType,
                String userTelephone, Date registerTime, boolean needChangePassword) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.userType = userType;
        this.userTelephone = userTelephone;
        this.registerTime = registerTime;
        this.needChangePassword = needChangePassword;
    }

    // 输入用户信息（子类可重写）
    public void inputUserInfo() {
        System.out.println("请输入用户ID:");
        this.id = scanner.nextInt();
        scanner.nextLine(); // 消耗换行符

        System.out.println("请输入用户名:");
        this.userName = scanner.nextLine();

        System.out.println("请输入密码:");
        this.password = scanner.nextLine();

        System.out.println("请输入用户类型:");
        this.userType = scanner.nextLine();

        System.out.println("请输入用户电话:");
        this.userTelephone = scanner.nextLine();

        this.registerTime = new Date(); // 自动设置注册时间
    }

    // 显示用户信息
    public void displayUserInfo() {
        System.out.println("用户信息如下:");
        System.out.println("ID: " + id);
        System.out.println("用户名: " + userName);
        System.out.println("用户类型: " + userType);
        System.out.println("电话: " + userTelephone);
        System.out.println("注册时间: " + registerTime);
    }

    // Getter和Setter
    public int getId() { return id; }
    public void setId(int id) { this.id = id; }
    public String getUserName() { return userName; }
    public void setUserName(String userName) { this.userName = userName; }
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }
    public String getUserType() { return userType; }
    public void setUserType(String userType) { this.userType = userType; }
    public String getUserTelephone() { return userTelephone; }
    public void setUserTelephone(String userTelephone) { this.userTelephone = userTelephone; }
    public Date getRegisterTime() { return registerTime; }
    public void setRegisterTime(Date registerTime) { this.registerTime = registerTime; }
    public boolean isNeedChangePassword() { return needChangePassword; }
    public void setNeedChangePassword(boolean needChangePassword) { this.needChangePassword = needChangePassword; }
}